<?php

/*
 * This file is part of the php-phantomjs.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace lemon\phantomjs\Procedure;

use lemon\phantomjs\Engine;
use lemon\phantomjs\Cache\CacheInterface;
use lemon\phantomjs\Parser\ParserInterface;
use lemon\phantomjs\Template\TemplateRendererInterface;

/**
 * PHP PhantomJs
 *
 * @author Jon Wenmoth <contact@jonnyw.me>
 */
class ProcedureFactory implements ProcedureFactoryInterface
{
	/**
	 * PhantomJS engine
	 *
	 * @var \lemon\phantomjs\Engine
	 * @access protected
	 */
	protected $engine;

	/**
	 * Parser.
	 *
	 * @var \lemon\phantomjs\Parser\ParserInterface
	 * @access protected
	 */
	protected $parser;

	/**
	 * Cache handler.
	 *
	 * @var \lemon\phantomjs\Cache\CacheInterface
	 * @access protected
	 */
	protected $cacheHandler;

	/**
	 * Template renderer.
	 *
	 * @var \lemon\phantomjs\Template\TemplateRendererInterface
	 * @access protected
	 */
	protected $renderer;

	/**
	 * Internal constructor.
	 *
	 * @access public
	 * @param \lemon\phantomjs\Engine							 $engine
	 * @param \lemon\phantomjs\Parser\ParserInterface			 $parser
	 * @param \lemon\phantomjs\Cache\CacheInterface			   $cacheHandler
	 * @param \lemon\phantomjs\Template\TemplateRendererInterface $renderer
	 */
	public function __construct(Engine $engine, ParserInterface $parser, CacheInterface $cacheHandler, TemplateRendererInterface $renderer){
		$this->engine	   = $engine;
		$this->parser	   = $parser;
		$this->cacheHandler = $cacheHandler;
		$this->renderer	 = $renderer;
	}

	/**
	 * Create new procedure instance.
	 *
	 * @access public
	 * @return \lemon\phantomjs\Procedure\Procedure
	 */
	public function createProcedure(){
		$procedure = new Procedure(
			$this->engine,
			$this->parser,
			$this->cacheHandler,
			$this->renderer
		);

		return $procedure;
	}
}
